/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.qp.smsmarketing.reports;

import com.qp.smsmarketing.dao.MensagemDAO;
import java.io.InputStream;
import java.sql.Connection;
import java.util.HashMap;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.util.JRLoader;
import net.sf.jasperreports.view.JasperViewer;
import org.hibernate.Session;

/**
 *
 * @author joasramos
 */
public class ReportEstatistica {
    
    /**
     * public static void criarRelatorioEtiquetasPequenasAusentes(
			Concurso concurso, Etapa etapa, String msgEtiqueta) {
		HashMap<String, Object> map = new HashMap<String, Object>();
		map.put("ID_CONCURSO", concurso.getId());
		map.put("ID_ETAPA", etapa.getId());
		map.put("MSG_ETIQUETA", msgEtiqueta);
		// System.out.println("CONCURSO: "+map.get("ID_CONCURSO"));

		JasperPrint jasperPrint = null;
		try {
			jasperPrint = JasperFillManager.fillReport(
					"relatorios/Relatorio_EtiquetasPequenasAusentes.jasper",
					map, new ConcursoDAO().getSession().connection());
		} catch (HibernateException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (JRException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		JasperViewer viewer = new JasperViewer(jasperPrint, false);
		viewer.show(true);

	}


     */
    @SuppressWarnings("deprecation")
    public void abrirRelatorioEstatistica(){
        JasperPrint print = null;
        HashMap <String, Object> map = new HashMap<String, Object>();
        Session session = new MensagemDAO().getSession();
//        InputStream is = getClass().getResourceAsStream("estatistica_enviadas.jasper");
        
        String arquivo = "estatistica_enviadas.jasper"; 
         
        try{    
            JasperReport jasperReport = (JasperReport) JRLoader.loadObject(arquivo);
            print = JasperFillManager.fillReport(jasperReport, null);  
 
        }catch(Exception e){
            System.out.println("ERRO!:"+ e);
        }
        
        new JasperViewer(print,false).setVisible(true);
        
        }
   
}
